export default function() {
    let mailListSearchModal = document.getElementsByClassName(
        "ant-modal-wrap"
    )[0];
    let dialogModal = mailListSearchModal.getElementsByClassName(
        "ant-modal-content"
    )[0];
    let dialogModalHead = mailListSearchModal.getElementsByClassName(
        "ant-modal-header"
    )[0];
    let _this = this,
        distX = 0,
        distY = 0,
        historyX = 0,
        historyY = 0
    dialogModalHead.onmouseover = function() {
        this.style.cursor = "move";
    };
    let dialogModalAttrs = window.getComputedStyle(dialogModal);
    dialogModalHead.onmousedown = function(e) {
        if (dialogModalHead.setCapture) {
            dialogModalHead.setCapture();
        }
        let ev = e || window.event,
            _x = ev.pageX,
            _y = ev.pageY;
        document.onmousemove = function(e) {
            let ev = e || window.event,
                x = ev.pageX - _x,
                y = ev.pageY - _y;
            // if (x <= 0) {
            //   distX = 0;
            // } else if (x > window.innerWidth - dialogModalHead.offsetWidth) {
            //   distX = window.innerWidth - dialogModalHead.offsetWidth;
            // } else {
            distX = x;
            // }
            // if (y <= 0) {
            //   distY = 0;
            // } else if (x > window.innerHeight - dialogModalHead.offsetHeight) {
            //   distY = window.innerHeight - dialogModalHead.offsetHeight;
            // } else {
            distY = y;
            // }
            dialogModal.style.transform = `translate(${distX +historyX}px,${distY + historyY}px)`;
        };
        document.onmouseup = function(e) {
            let ev = e || window.event;
            document.onmousemove = null;
            document.onmouseup = null;
            if (!(ev.pageX === _x && ev.pageY === _y)) {
                historyX = historyX + distX;
                historyY = historyY + distY;
            }
        };
    };
}
